import 'package:architecture/os_size.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

import 'device_info_controller.dart';

class DeviceInfoPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return GetX<DeviceInfoController>(
        init: DeviceInfoController(),
        builder: (controller) {
          return Scaffold(
              appBar: AppBar(title: Text('设备信息')),
              body: Container(
                width: windowWidth * 0.5,
                child: Column(
                  children: [
                    _itemLayout(
                      'name',
                      controller.deviceInfo['name'] ?? '',
                    ),
                    _itemLayout(
                      'os_version',
                      controller.deviceInfo['os_version'] ?? '',
                    ),
                    _itemLayout(
                      'long_os_version',
                      controller.deviceInfo['long_os_version'] ?? '',
                    ),
                    _itemLayout(
                      'host_name',
                      controller.deviceInfo['host_name'] ?? '',
                    ),
                    _itemLayout(
                      'cpu_arch',
                      controller.deviceInfo['cpu_arch'] ?? '',
                    ),
                    _itemLayout(
                      'distribution_id',
                      controller.deviceInfo['distribution_id'] ?? '',
                    ),
                  ],
                ),
              ));
        });
  }

  _itemLayout(String title, String content) {
    return Container(
        padding: EdgeInsets.all(10),
        child: Column(
          children: [
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Text(
                  title,
                  style: TextStyle(color: Colors.grey),
                ),
                Text(content),
              ],
            ),
            Container(
                margin: EdgeInsets.symmetric(vertical: 10),
                child: Divider(
                  height: 0.2,
                ))
          ],
        ));
  }
}
